#!/bin/bash
BASE_DIR="/project/next"

LOG_FILE="$BASE_DIR/logs/deploy.log"

mkdir -p "$BASE_DIR/logs"

echo "🚀 开始部署: $(date)" >> "$LOG_FILE"

cd "$BASE_DIR" || exit

git fetch origin master >> "$LOG_FILE" 2>&1

git reset --hard origin/master >> "$LOG_FILE" 2>&1

pnpm install >> "$LOG_FILE" 2>&1

pnpm run build >> "$LOG_FILE" 2>&1

pm2 restart next >> "$LOG_FILE" 2>&1

echo "✅ 部署完成: $(date)" >> "$LOG_FILE"
